package com.kasax.plugin.app.visitor.clickclass

import com.kasax.plugin.app.LogUtils
import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes


class ClickClassVisitor extends ClassVisitor {
    final String TAG = "ClickClassVisitor"

    ClickClassVisitor(ClassVisitor classVisitor) {
        super(Opcodes.ASM7, classVisitor)
    }

    @Override
    MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
        LogUtils.d(TAG, "------------ ------------   ClickClassVisitor visitMethod 开始  ------------ ------------  ")
        MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions)
        // 判断 方法
        if (name.startsWith("onClick")) {
            LogUtils.d(TAG, "find onclick method: $name")
            // 处理点击方法
            return new ClickMethodVisitor(mv)
        }
        LogUtils.d(TAG, "------------ ------------   ClickClassVisitor visitMethod 结束  ------------ ------------  ")
        return mv
    }
}